#ifndef _MENU_H_
#define _MENU_H_

#include <interfacelib/window/window.h>
#include <D3D9.h>
#include <d3dx9core.h>

#include <utillib/string/string.h>
#include <interfacelib/window/box.h>

#pragma warning ( disable : 4786 )
#include <deque>
#include <functional>

namespace interfacelib
{
	namespace Window
	{
		class Menu : public interfacelib::Window::Window
		{
		public:
			struct MenuItem
			{
				int index;
				int xpos;
				utillib::string::String string;
				void *reserve;
			};
			typedef std::deque < MenuItem * > dequeMenuItem;
		public:
			Menu();
			virtual ~Menu();

			void addMenu( int index, const char *string , void *reserve = NULL , int xpos = 0 );
			void removeMenu( int index );
			void setMenuItem( int index, const char *string = NULL, void *reserve = NULL , int xpos = 0 );

			void setSelectedForeColor( DWORD color ){ m_selectForeColor = color; };
			void setSelectedBackColor( DWORD color ){ m_selectBox.setColor( color ); };

			void *getItemData( int index );

			virtual	void draw( Window *checkWindow = NULL );

			void setMarginHeight( int height ){ m_marginHeight = height; };
			void setTextYPos( int ypos )    { m_textYPos = ypos;     };


			virtual void onMouseMove( UINT flags, POINT point );
			virtual	void onLButtonUp( UINT flags, POINT point );
			void onMouseOut( LONG x, LONG y );

			MenuItem* getCurrentItem()   {  return m_currentMousePointMenu;		};
		private:
			void release();
			void calcWindowRect();

			MenuItem *getMenuItemPos( DWORD x,  DWORD y );
			dequeMenuItem m_menuItemList;

			MenuItem *m_currentMousePointMenu;
			Box m_selectBox;
			int m_marginHeight;

			DWORD m_selectForeColor;

			int m_textYPos;

			bool m_isAutoResize;
		};
	}
}

#endif